package bysj.service;

import bysj.dao.StudentClassDao;
import bysj.domain.StudentClass;
import util.Condition;
import util.JdbcHelper;
import util.Pagination;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;

public class StudentClassService {
    private static StudentClassDao studentClassDao = StudentClassDao.getInstance();
    private static StudentClassService studentClassService = null;

    public static StudentClassService getInstance(){
        if(studentClassService ==null){
            studentClassService = new StudentClassService();
        }
        return studentClassService;
    }
    public Collection<StudentClass> findAll(List<Condition>conditionList, Pagination pagination) throws SQLException {
        Connection connection = JdbcHelper.getConn();
        Collection<StudentClass> students = studentClassDao.findAll(connection,conditionList,pagination);
        JdbcHelper.close(connection);
        return  students;
    }

    public StudentClass find(Integer id) throws SQLException {
        Connection connection = JdbcHelper.getConn();
        StudentClass studentClass = studentClassDao.find(id,connection);
        JdbcHelper.close(connection);
        return studentClass;
    }
}
